﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace ashx
{
    /// <summary>
    ///DeleteFile 的摘要描述
    /// </summary>
    public class DeleteFile : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            if (!string.IsNullOrEmpty(context.Request["DeleteFileName"]))
            {
                try
                {
                    string filePath = (context.Server.MapPath(context.Request["DeleteFileName"].ToString())).Replace("ashx", @"Files\Templates");

                    if (System.IO.File.Exists(filePath))
                    {
                        FileInfo file = new FileInfo(filePath);
                        file.Delete();
                    }
                }
                catch { }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}